import { v4 as uuidv4 } from 'uuid';
import { Seeder } from '../../umzug';

const classifications = [
  '身体健康',
  '心理健康',
  '压力源',
  '应对方式'
];

const newClassifications = classifications.map((item, index) => (
  {
    id: index + 1,
    uuid: uuidv4(),
    name: item,
    created_at: new Date(),
    updated_at: new Date()
  }
));

export const up: Seeder = async ({ context: sequelize }) => {
  await sequelize
    .getQueryInterface()
    .bulkInsert('classifications', newClassifications);
};

export const down: Seeder = async ({ context: sequelize }) => {
  await sequelize
    .getQueryInterface()
    .bulkDelete(
      'classifications',
      { id: newClassifications.map((u) => u.id) }
    );
};
